#include <gtest/gtest.h>

#include "BinaryTreeExample.h"

using namespace testing;

class BinaryTreeExampleTest : public Test {
public:
    BinaryTreeExampleTest() = default;
protected:
    void SetUp() override {
        TreeNode* node1 = new TreeNode(1);
        TreeNode* node3 = new TreeNode(3);
        TreeNode* node6 = new TreeNode(6);
        TreeNode* node9 = new TreeNode(9);
        TreeNode* node2 = new TreeNode(2, node1, node3);
        TreeNode* node7 = new TreeNode(7, node6, node9);
        invertTree = new TreeNode(4, node2, node7);
    }
    BinaryTreeExample _example;

    TreeNode* invertTree = nullptr;
};

TEST_F(BinaryTreeExampleTest, InvertTree_Test_case001)
{
    TreeNode* res = _example.InvertTree(invertTree);
    EXPECT_EQ(4, res->val);
    EXPECT_EQ(7, res->left->val);
    EXPECT_EQ(2, res->right->val);
    EXPECT_EQ(9, res->left->left->val);
    EXPECT_EQ(6, res->left->right->val);
    EXPECT_EQ(3, res->right->left->val);
    EXPECT_EQ(1, res->right->right->val);
}
